import requests
import json
from pyquery import PyQuery as jq
from urllib.parse import urljoin
url = "https://www.xxbiquge.com/75_75933/"
headers = json.loads(r'''{
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Cache-Control": "max-age=0",
    "Connection": "keep-alive",
    "Cookie": "bcolor=; font=; size=; fontcolor=; width=; PPad_id_PP=3",
    "Host": "www.xxbiquge.com",
    "If-Modified-Since": "Tue, 04 Sep 2018 10:00:39 GMT",
    "If-None-Match": "W/\"5b8e57c7-338a0\"",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
}''')
def getContent(urls,index,name):
	resp = requests.get(urls)
	resp.encoding = 'utf-8'
	content = jq(resp.text)('#content').text()
	with open(f'{index}{name}.html','w',encoding='utf-8') as f:
		f.write(content)


resp = requests.get(url)
resp.encoding = 'utf-8'
dl = jq(resp.text)('#list > dl')
for index,i in enumerate(dl('dd').items()):
	url = urljoin("https://www.xxbiquge.com/",i('a').attr('href'))
	text = i('a').text()
	getContent(url,index,text)
    